<template>
    <div id="pie" :style="chart_style">
    </div>
</template>

<script>
  import {getHomeData} from '@/api/home.js'
  export default {
    name:"PieChart",
    props:['chart_style'],
    data(){
       return {
         option:{
              title: {
                  text: "认证用户比例",
                  subtext: '单位：百分比',
                  left: 'center'
              },
              tooltip: {
                  trigger: 'item'
              },
              series: [
                  {
                      name: '认证百分比',
                      type: 'pie',
                      radius: '50%',
                      data: [],
                      emphasis: {
                          itemStyle: {
                              shadowBlur: 10,
                              shadowOffsetX: 0,
                              shadowColor: 'rgba(0, 0, 0, 0.5)'
                          }
                      }
                  }
              ]
          }
       }
    },
    mounted() {
      let chartDom = document.getElementById('pie');
      let myChart = echarts.init(chartDom);
      let that=this;
      getHomeData({type:'pie'}).then(function(response){
          if(response.data.code==1){
              that.option.series[0].data=response.data.list;
              myChart.setOption(that.option);
          }
      })
    }
  }
</script>

<style>
</style>
